<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>任务标注</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="../lib/layui/css/layui.css">
    <link rel="stylesheet" href="../css/scroll-bar.css">
    <link rel="stylesheet" href="../css/sub-page.css">
    <link rel="stylesheet" href="../css/font.css">
    <link rel="stylesheet" href="../lib/nprogress/nprogress.css">
</head>

<body>
    <div class="ok-body">
        <!--面包屑导航区域-->
        <div class="ok-body-breadcrumb">
            <span class="layui-breadcrumb">
                <a><cite>首页</cite></a>
                <a><cite>任务管理</cite></a>
                <a><cite>任务标注</cite></a>
            </span>
            <a class="layui-btn layui-btn-small" href="javascript:location.replace(location.href);" title="刷新">
                <i class="layui-icon layui-icon-refresh"></i>
            </a>
        </div>
        <!--模糊搜索区域-->
        <!--  <div class="layui-row ok-search">
            <input class="layui-input" placeholder="开始日期" autocomplete="off" id="startTime">
            <input class="layui-input" placeholder="截止日期" autocomplete="off" id="endTime">
            <div class="layui-inline">
                <input class="layui-input" name="id" id="taskname" autocomplete="off" placeholder="请输入任务名称">
            </div>
            <button class="layui-btn" data-type="reload" id="search">搜索</button>
        </div> -->
        <!--工具栏-->
        <!-- <okToolbar>
            <button class="layui-btn" id="add">
                <i class="layui-icon">&#xe61f;</i>新建任务
            </button>
            <span>共有数据：<i id="countNum">0</i> 条</span>
        </okToolbar> -->
        <!--数据表格-->
        <table class="layui-hide" id="tableId" lay-filter="tableFilter"></table>
    </div>
    <!--js逻辑-->
    <script src="../lib/layui/layui.js"></script>
    <script src="../lib/nprogress/nprogress.js"></script>
    <script>
        NProgress.start();
    window.onload = function () {
        NProgress.done();
    }
    layui.use(['element', 'table', 'form', 'jquery'], function () {
        var element = layui.element;
        var table = layui.table;
        var form = layui.form;
        var $ = layui.jquery;
       /*  var laydate = layui.laydate;
        laydate.render({
            elem: '#startTime',
            type: "datetime"
        });

        laydate.render({
            elem: '#endTime',
            type: "datetime"
        }); */
        table.render({
            elem: '#tableId',
            url: '/task/actionlist',
            limit: 10,
            cellMinWidth: 80,
            page: true,
            id:'folderlist',
            where: {
                        action: '<%=action%>'
                    },
            cols: [[
                {field: 'taskid', title: 'ID', width: 80, sort: true},
                {field: 'taskname', title: '任务名'},
                {field: 'totalcount', title: '任务量', width: 80},
                {field: 'actions', title: '执行类别', templet: '#actionTpl'},
                {field: 'username', title: '任务管理员'},
                {field: 'tasktags', title: '任务标签'},
                {field: 'description', title: '任务描述'},
                {field: 'createat', title: '创建时间'},
                /* {field: 'status', title: '状态', width: 85, templet: '#statusTpl'}, */
                {title: '操作', templet: '#operationTpl', align: 'center'}
            ]]
        });

        var active = {
            reload: function(){
                var taskname = $('#taskname').val();
                var start=$('#startTime').val();
                var end=$('#endTime').val();
                
                //执行重载
                table.reload('folderlist', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    ,where: {
                        action: '<%=action%>'
                    }
                });
            }
        };

    /*     $('#search').on('click', function(){
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
        $('#taskname').on('keydown',function(e){
            if(e.keyCode=='13'){
                $('#search').click();
            }
        }); */

        table.on('tool(tableFilter)', function (obj) {
            var data = obj.data;
            var layEvent = obj.event;
            if (layEvent === 'action') {
                switch (data.actions) {
                    case 0://数据筛选
                          var clayer= layer.open({
                            title: '标注任务--'+data.taskname,
                            type: 2,
                            shade: false,
                            //maxmin: true,
                            shade: 0.5,
                            area: ['100%', '100%'],
                            content: '/task/classify_mark?dsid='+ data.dsid,
                            zIndex: layer.zIndex,
                            end: function () {
                                $(".layui-laypage-btn")[0].click();
                            },
                            success:function(layero, index){
                                var body = layer.getChildFrame('body', index);
                                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                                body.find('#id').val(data.dsid);
                                console.log('dsid='+body.find('#id').val());

                                body.find('#taskid').val(data.taskid);
                                console.log('taskid='+body.find('#taskid').val());
                                //layer.full(clayer);
                            }
                        });
                        break;
                        case 1://单分类
                       
                        layer.open({
                            type: 2
                            ,title: false //不显示标题栏
                            ,closeBtn: false
                            , area: ['100%', '100%']
                            ,shade: 0.8
                            ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
                            ,btn: ['我同意']
                            ,btnAlign: 'c'
                            ,moveType: 1 //拖拽模式，0或者1
                            ,content: '/task/aggreement?desc='+encodeURIComponent(data.description)
                            ,success: function(layero,index){
                                /* var body = layer.getChildFrame('body', index);
                                var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                                body.find('#description').html(data.description);
                                //console.log(body.find('#description').html()); */

                                var btn = layero.find('.layui-layer-btn');
                                btn.click(function(){
                                    layer.open({
                                        title: '标注任务--'+data.taskname,
                                        type: 2,
                                        shade: false,
                                        //maxmin: true,
                                        shade: 0.5,
                                        area: ['100%', '100%'],
                                        content: '/task/single_mark',
                                        zIndex: layer.zIndex,
                                        end: function () {
                                            $(".layui-laypage-btn")[0].click();
                                        },
                                        success:function(layero, index){
                                            var body = layer.getChildFrame('body', index);
                                            var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                                            body.find('#id').val(data.dsid);
                                            console.log('dsid='+body.find('#id').val());

                                            body.find('#taskid').val(data.taskid);
                                            console.log('taskid='+body.find('#taskid').val());
                                            //layer.full(clayer);
                                        }
                                    });
                                });
                            }
                        });
                break;
                
                case 2://多分类
                layer.open({
                            type: 2
                            ,title: false //不显示标题栏
                            ,closeBtn: false
                            , area: ['100%', '100%']
                            ,shade: 0.8
                            ,id: 'LAY_layuipro' //设定一个id，防止重复弹出
                            ,btn: ['我同意']
                            ,btnAlign: 'c'
                            ,moveType: 1 //拖拽模式，0或者1
                            ,content: '/task/aggreement?desc='+encodeURIComponent(data.description)
                            ,success: function(layero,index){
                                var btn = layero.find('.layui-layer-btn');
                                btn.click(function(){
                                    layer.open({
                                        title: '标注任务--'+data.taskname,
                                        type: 2,
                                        shade: false,
                                        //maxmin: true,
                                        shade: 0.5,
                                        area: ['100%', '100%'],
                                        content: '/task/muti_mark',
                                        zIndex: layer.zIndex,
                                        end: function () {
                                            $(".layui-laypage-btn")[0].click();
                                        },
                                        success:function(layero, index){
                                            var body = layer.getChildFrame('body', index);
                                            var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                                            body.find('#id').val(data.dsid);
                                            console.log('dsid='+body.find('#id').val());

                                            body.find('#taskid').val(data.taskid);
                                            console.log('taskid='+body.find('#taskid').val());
                                            //layer.full(clayer);
                                        }
                                    });
                                });
                            }
                        });
                break;
                    default:
                        break;
                }
             
                
            } 
        
        });
    })
</script>
    <script type="text/html" id="operationTpl">
        <a href="javascript:;" title="进入任务" lay-event="action" class="layui-btn layui-btn-xs layui-bg-blue">进入任务</a>
</script>

    <script type="text/html" id="actionTpl">
        <!-- <input type="checkbox" name="status" value="{{d.userid}}" lay-filter='status_switch' lay-skin="switch" lay-text="完成|进行" {{ d.status== 1 ? 'checked' : ''}}> -->
<a href="javascript:;" title="执行类别"  class="layui-btn layui-btn-xs">
        {{#  if(d.actions === 0){ }}
        数据筛选
        {{#  } }}     
       {{#  if(d.actions === 1){ }}
        单分类
        {{#  } }}
        {{#  if(d.actions === 2){ }}
        多分类
        {{#  } }}  
</a>
</script>
</body>

</html>